<template>
  <div class="breadcrumb">
    <span v-for="(item, index) in this.$route.matched" :key="index">
      <span v-if="index != $route.matched.length - 1">
        <a href="item.path">{{ item.meta.breadcrumb }}</a></span
      >
      <span v-else> {{ item.meta.breadcrumb }}</span>
      <!-- 优化,如果breadcrumb是最后一个,就不要"->" -->
      <span v-if="index != $route.matched.length - 1">-></span>
    </span>
  </div>
</template>

<script>
export default {
  //   忘记了可以试着打印this.$route.matched,他是一个数组
  mounted() {
    // console.log(1111, this.$route.matched);
  },
};
</script>
<style lang="less" scoped>
.breadcrumb {
  margin-bottom: 30px;
}
</style>